package org.breathe.thread.pool.common.enums;

import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.ThreadPoolExecutor;

/**
 * 拒绝策略的枚举类
 * @author: breathe
 * @createTime: 2025-04-09
 */
@Slf4j
@Getter
public enum RejectedTypeEnum {

    ABORT_POLICY("AbortPolicy", new ThreadPoolExecutor.AbortPolicy()),
    CALLER_RUNS_POLICY("CallerRunsPolicy", new ThreadPoolExecutor.CallerRunsPolicy()),
    DISCARD_OLDEST_POLICY("DiscardOldestPolicy", new ThreadPoolExecutor.DiscardOldestPolicy()),
    DISCARD_POLICY("DiscardPolicy", new ThreadPoolExecutor.DiscardPolicy())
    ;

    private final String name;
    private final RejectedExecutionHandler handler;
    RejectedTypeEnum(String name, RejectedExecutionHandler handler) {
        this.name = name;
        this.handler = handler;
    }
}
